package com.voice.call.service.impl;


import javax.annotation.Resource;

import org.springframework.context.MessageSource;
import org.springframework.stereotype.Service;

import com.voice.call.common.ConstLang;
import com.voice.call.service.LocalizationSerivce;


@Service
public class LocalizationSerivceImpl implements LocalizationSerivce{
	
	@Resource
	private MessageSource messageSource;
	
	@Override
	public String getLocalForKey(String code,String lang){
		
		try {
			
			// 德语，阿拉伯语 , 法语
			
			//Locale.FRENCH; //法语
			//Locale.ENGLISH; //英语
			//Locale.GERMAN; //德语
			//Locale.GERMAN; //阿拉伯语
			ConstLang ctLang = new ConstLang(code,lang);
			String msg=messageSource.getMessage(ctLang.getCode(), new Object[]{}, ctLang.getLocale());
			
			return msg;
		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
		
	}

}
